<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: mslaria $ ($Date: 2006/11/09 12:32:42 $)
// $RCSfile: staff_massreply.php,v $ : $Revision: 1.3 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

$template->loadLanguageSection("staff_massreply");

$_assigns = getAssignedDepartments(MODULE_TICKETS);
renderTicketTree();

$template->assign("calendar", true);
$template->assign("spellcheck", true);

$interface->staffHeader($_SWIFT["language"]["tickets"] ." &gt; ".$_SWIFT["language"]["massreply"], 2);

$interface->staffNavBar('<a href="index.php?_m=tickets&_a=manage" title="'.$_SWIFT["language"]["tickets"].'">'.$_SWIFT["language"]["tickets"].'</a> &raquo; '.$_SWIFT["language"]["massreply"], "", 2);

printInfoBox($_SWIFT["infomessage"]);
printErrorBox($errormessage);

?>
<script type="text/javascript">
selectedTab = "reply";
</script>
<?

printFormStart("replyform", "index.php", "POST", true);
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%" class="tborder">'.SWIFT_CRLF;
echo '<thead><tr>'.SWIFT_CRLF;

echo '<td class="tcat" width="1" align="left" nowrap><img src="'. $_SWIFT["themepath"] .'space.gif" width="4" height="21"></td>'.SWIFT_CRLF;
echo '<td class="tcat" align="left" nowrap>'. $_SWIFT["language"]["massreply"] .'</td>'.SWIFT_CRLF;
echo '</tr>'.SWIFT_CRLF;
echo '</thead>'.SWIFT_CRLF;

echo '<tbody><tr><td class="contenttableborder" colspan="2"><table border="0" cellpadding="3" cellspacing="1" width="100%">'.SWIFT_CRLF;
echo '<tr class="'. getRowBG() .'">
<td width="100" align="left"><span class="tabletitle">'. $_SWIFT["language"]["from"] .'</span></td>
<td align="left"><select name="opt_emailqueueid" class="swiftselect">';
// 1st - Queue Emails
$firston = true;
foreach ($_SWIFT["queuecache"]["list"] as $key=>$val)
{
	if ($firston)
	{
		$seltext = " selected";
		$firston = false;
	}
	$fromname = iif(empty($val["customfromname"]), $_SWIFT["staff"]["fullname"], $val["customfromname"]);
	$fromemail = iif(empty($val["customfromemail"]), $val["email"], $val["customfromemail"]);
	echo '<option value="'. intval($val["emailqueueid"]) .'"'. $seltext .'>'. htmlspecialchars($fromname) .' &lt;'. htmlspecialchars($fromemail) .'&gt;</option>'.SWIFT_CRLF;
}
// 2nd - Personal Email
echo '<option value="0">'. htmlspecialchars($_SWIFT["staff"]["fullname"]) .' &lt;'. htmlspecialchars($_SWIFT["staff"]["email"]) .'&gt;</option>'.SWIFT_CRLF;
echo '</select></td></tr>';

echo '<tr class="'. getRowBG() .'">
<td width="100" align="left" id="fmenuref"><span class="tabletitle">'. $_SWIFT["language"]["quickinsert"] .'</span></td>
<td align="left"><a href="#" title="'. $_SWIFT["qpredefinedreplies"] .'" id="fprcachelink" onClick="javascript:CustomPopupRef(\'prcachemenu\', event, \'fprcachelink\', \'prcachemenu\', \'fmenuref\', prmenuloaded);this.blur();" onMouseUp="javascript:this.blur();"><img src="'. $_SWIFT["themepath"] .'icon_quickinsert.gif" border="0" align="absmiddle" />&nbsp;'. $_SWIFT["language"]["qpredefinedreplies"] .'&nbsp;<img src="'. $_SWIFT["themepath"] .'menudrop.gif" border="0" align="absmiddle" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" title="'. $_SWIFT["qknowledgebase"] .'" id="fkbcachelink" onClick="javascript:CustomPopupRef(\'kbcachemenu\', event, \'fkbcachelink\', \'kbcachemenu\', \'fmenuref\', kbmenuloaded);this.blur();" onMouseUp="javascript:this.blur();"><img src="'. $_SWIFT["themepath"] .'icon_quickinsert.gif" border="0" align="absmiddle" />&nbsp;'. $_SWIFT["language"]["qknowledgebase"] .'&nbsp;<img src="'. $_SWIFT["themepath"] .'menudrop.gif" border="0" align="absmiddle" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" title="'. $_SWIFT["qdownloads"] .'" id="fdlcachelink" onClick="javascript:CustomPopupRef(\'dlcachemenu\', event, \'fdlcachelink\', \'dlcachemenu\', \'fmenuref\', dlmenuloaded);this.blur();" onMouseUp="javascript:this.blur();"><img src="'. $_SWIFT["themepath"] .'icon_quickinsert.gif" border="0" align="absmiddle" />&nbsp;'. $_SWIFT["language"]["qdownloads"] .'&nbsp;<img src="'. $_SWIFT["themepath"] .'menudrop.gif" border="0" align="absmiddle" /></a>&nbsp;&nbsp;&nbsp;</td>
</tr>';

	printDescRow($_SWIFT["language"]["contents"]);
	$colarray = array();
	$colarray[0]["align"] = "left";
	$colarray[0]["valign"] = "top";
	$colarray[0]["colspan"] = "2";
	$colarray[0]["nowrap"] = true;
	$colarray[0]["value"] = '<textarea style="WIDTH:100%;" name="replycontents" cols="100" rows="15" tabindex="99" onselect="javascript:storeCaret(this);" onclick="javascript:storeCaret(this);" onkeyup="javascript:storeCaret(this);">'. htmlspecialchars($_POST["replycontents"]) .'</textarea>'.SWIFT_CRLF;
	$colarray[0]["class"] = getRowBG();
	printDataRow($colarray);

	echo '<tr class="'. getRowBG() .'">
	<td width="100" align="left"><span class="tabletitle">'. $_SWIFT["language"]["options"] .'</span></td>
	<td align="left"><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="180" nowrap><span class="smalltext">'. $_SWIFT["language"]["pdue"] .'<input type="text" name="opt_due" id="opt_fdue" onclick="return showCalendar(\'opt_fdue\', \''.iif($_SWIFT["settings"]["dt_caltype"]=="us", "%m/%d/%Y", "%d/%m/%Y").'\');" size="12" readonly="1" value="" class="swifttext"/>&nbsp;<img src="'. $_SWIFT["themepath"] .'calendar.gif" id="opt_fduet" onclick="return showCalendar(\'opt_fdue\', \''.iif($_SWIFT["settings"]["dt_caltype"]=="us", "%m/%d/%Y", "%d/%m/%Y").'\');" style="cursor: pointer;" align="absmiddle"/></span></td><td nowrap><span class="smalltext">'. $_SWIFT["language"]["ptimeworked"] .'<input type="text" name="opt_timeworked" size="12" value="'. $_SWIFT["language"]["inminutes"] .'" onclick="javascript:if(this.value==\''. $_SWIFT["language"]["inminutes"] .'\') { this.value=\'\'; }" class="swifttext"/>&nbsp;</span></td></tr></table>
</td>
	</tr>';

	// ======= ADD NOTE =======
	echo '<tr class="descrow" title="" onmouseover="" onmouseout="" onclick="" id="fnote1" style="DISPLAY: none;">
<td class="descrow" align="left" valign="top" colspan="2" width="">'. $_SWIFT["language"]["noteoptions"] .'</td>
</tr>
<tr class="row1" title="" onmouseover="" onmouseout="" onclick="" id="fnote2" style="DISPLAY: none;">
<td class="row1" align="left" valign="top" colspan=""><span class="tabletitle">'.$_SWIFT["language"]["notetype"].'</span></td>
<td class="row1" align="left" valign="top" colspan=""><label for="fnotetype[0]"><input type="radio" id="fnotetype[0]" name="notetype" value="'. NOTE_TICKET .'" checked /> <span class="smalltext">'. $_SWIFT["language"]["ticket"] .'</label></span>

<label for="fnotetype[1]"><input type="radio" id="fnotetype[1]" name="notetype" value="'. NOTE_USER .'" /> <span class="smalltext">'. $_SWIFT["language"]["user"] .'</label></span>
</td>
</tr>
<tr class="row2" title="" onmouseover="" onmouseout="" onclick="" id="fnote3" style="DISPLAY: none;">
<td class="row1" align="left" valign="top" colspan="2" width=""><textarea style="WIDTH:100%;" name="notecontents" cols="100" rows="3">'. htmlspecialchars($_POST["notecontents"]) .'</textarea>
</td>
</tr>';

	// ======= ATTACH FILES =======
	$attachrowjs = "switchDisplay('attach0');";
	echo '<tr class="descrow" title="" onmouseover="" onmouseout="" onclick="" id="attach0" style="DISPLAY: none;">
<td class="descrow" align="left" valign="top" colspan="2" width="">'. $_SWIFT["language"]["attachfile"] .'</td>
</tr>';

$index = 1;
if (empty($_SWIFT["settings"]["t_maxattach"]))
{
	$maxattach = 3;
} else {
	$maxattach = intval($_SWIFT["settings"]["t_maxattach"]);
}

for ($ii=0; $ii<$maxattach; $ii++)
{
	$rowclass = getRowBG();
	$attachrowjs .= "switchDisplay('attach". $index ."');";
	echo '<tr class="'. $rowclass .'" title="" onmouseover="" onmouseout="" onclick="" id="attach'. $index .'" style="DISPLAY: none;">
<td class="'. $rowclass .'" align="left" valign="top" colspan=""><span class="tabletitle">'.sprintf($_SWIFT["language"]["attachfilen"], $index).'</span></td>
<td class="'. $rowclass .'" align="left" valign="top" colspan=""><input type="file" name="opt_file['. $index .']" value="" size="35" class="swifttext" />
</td>
</tr>';
	$index++;
}

	// ======= DOWNLOADS LINK =======
	echo '<tr class="descrow" title="" onmouseover="" onmouseout="" onclick="" id="downloads1" style="DISPLAY: none;">
<td class="descrow" align="left" valign="top" colspan="2" width="">'. $_SWIFT["language"]["qdownloads"] .'</td>
</tr>

<tr class="row1" title="" onmouseover="" onmouseout="" onclick="" id="downloads2" style="DISPLAY: none;">
<td class="row1" align="left" valign="top" colspan="2"><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr><td width="400" align="left"><select name="opt_downloads[]" class="swiftselect" size="5" style="WIDTH: 100%;" multiple></select></td><td align="left" valign="middle"><input type="button" onClick="javascript:removeDLItem();" class="bluebuttonsuperbig" value="'. $_SWIFT["language"]["removefile"] .'" /><BR /><BR /><BR /><input type="button" class="bluebuttonsuperbig" onClick="javascript:clearDLItems();" value="'. $_SWIFT["language"]["cancel"] .'" /></td></tr></table>
</td>
</tr>
';

	$data[0]["value"] = '<input type="submit" class="yellowbuttonbig" onClick="javascript:processReplyForm();" value="'. $_SWIFT["language"]["send"] .'" />&nbsp;&nbsp;<input type="button" onClick="javascript:switchDisplay(\'fnote1\');switchDisplay(\'fnote2\');switchDisplay(\'fnote3\');" class="bluebuttonbig" value="'. $_SWIFT["language"]["addnote"] .'" />&nbsp;&nbsp;<input type="button" onClick="javascript:'. $attachrowjs .'" class="bluebuttonbig" value="'. $_SWIFT["language"]["attachfile"] .'" />&nbsp;&nbsp;<input type="button" onClick="javascript:openSpellChecker();" class="bluebuttonbig" value="'. $_SWIFT["language"]["spellcheck"] .'" />&nbsp;&nbsp;'.SWIFT_CRLF;
	$data[0]["align"] = "left";
	$data[0]["colspan"] = 2;
	printDataRow($data);

	echo '</table></td></tr></tbody>'.SWIFT_CRLF;
	echo '</table><BR /> ';
	addHiddenField("_m", "tickets");
	addHiddenField("_a", "ticketactions");
	addHiddenField("action", "massreply");
	foreach ($_POST["itemid"] as $key=>$val)
	{
		addHiddenField("ticketids[]", intval($val));
	}
	printFormEnd();

	$interface->staffFooter();
?>